package hr.controllers;

import hr.models.Person;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

/**
 * Created with IntelliJ IDEA.
 * User: VMoskalenko
 * Date: 22.06.12
 * Time: 18:01
 */
@Controller
public class PersonCRUDController {

    @RequestMapping(method = RequestMethod.POST, value = "/person/create")
    public String submitCreateNewPerson(@ModelAttribute Person person) {
        return "person_list";
    }

    @RequestMapping(method = RequestMethod.GET, value = "/person/create")
    public String createNewPersonForm(HttpServletRequest request) {
        request.setAttribute("createPerson", new Person());
        return "create_person";
    }
}
